{% extends "base.html" %}

{% block content %}
<h3 class="mb-4">Todo List</h3>


<table class="responsive-table highlight" >
  <thead>
    <tr>
        <th>#</th>
        <th>TASK</th>
        <th>UPDATE</th>
        <th>WEEKLY</th>
        <th>PRIVILEGE</th>
        <th>DONE</th>
        <th>ACTION</th>
        <th>DETAILS</th>
    </tr>
  </thead>

  <tbody>
      {% for todo in todos %}
      <tr>
          <td>{{ todo.id }}</td>
          <td>{{ todo.task }}</td>
          <td>{{ todo.updated_at }}</td>
          <td>{{ todo.weekly }}</td>
          <td>{{ todo.privilege }}</td>
          <td>
              <a href="{{ url_for('toggle', todo_id=todo.id, page=todos.page) }}" class="waves-effect waves-light btn">
              {% if todo.completed %}
                  Yes
                  {% else %}
                  No
              {% endif %}
              </a>
          </td>
          <td>
              <a href="{{ url_for('delete', todo_id=todo.id, page=todos.page) }}" class="waves-effect waves-light btn">Delete</a>
          </td>
          <td>
              <a href="{{ url_for('todo_details', todo_id=todo.id) }}" class="waves-effect waves-light btn">Details</a>
          </td>
      </tr>
      
      {% endfor %}
  </tbody>
</table>
<ul class="pagination">
    {% if todos.has_prev %}
        <li class="active"><a href="{{ url_for('index', page=todos.prev_num) }}">L</a></li>
    {% else %}
        <li class="disabled"><a>L</a></li>
    {% endif %}
    {% for page_num in range(1, total_pages + 1) %}
        <li class="waves-effect {% if page_num == todos.page %}active{% endif %}"><a href="{{ url_for('index', page=page_num) }}">{{ page_num }}</a></li>
    {% endfor %}
    {% if todos.has_next %}
        <li class="active"><a href="{{ url_for('index', page=todos.next_num) }}">R</a></li>
    {% else %}
        <li class="disabled"><a>R</a></li>
    {% endif %}
</ul>
{% endblock %}
